package Person.Fanshe.ith_04;



import Person.Fanshe.ith_01.Student;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectDemo03 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class<?> c = Class.forName("Person.Fanshe.ith_01.Student");

       // Method[] m1 = c.getMethods();
        Method[] m1 = c.getDeclaredMethods();
        for(Method m:m1){
    System.out.println(m);
}
        System.out.println("**************");
        Method m = c.getMethod("method1");
       //获取无参构造方法创建对象
        Constructor<?> con = c.getConstructor();
        Object obj = con.newInstance();
 m.invoke(obj);


        Student s = new Student();



    }
}
